#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;

int dis[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int h, w, r, c;
    cin >> h >> w >> r >> c;

    int res = 0;

    for(int i = 0; i < 4; i ++){
        int nr = r + dis[i][0], nc = c + dis[i][1];

        if(nr < 1 || nr > h || nc < 1 || nc > w) continue;
        res ++;
    }

    cout << res << '\n';

    return 0;
}